package com.tywj.terminalapp.utils;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * crate by TaylorJoe
 *
 */
public abstract class BaseActivity extends AppCompatActivity {

    private Unbinder unbinder;

    @LayoutRes
    protected abstract int getContentId();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getContentId());
        unbinder = ButterKnife.bind(this);
        initWidget(savedInstanceState);
        initData();
        initClick();
    }

    protected void initClick() {
    }

    protected void initData() {
    }

    protected void initWidget(Bundle savedInstanceState) {
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (unbinder!=null)
            unbinder.unbind();
    }
}
